home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / PIBLIST.PAS < prev    next >
Pascal/Delphi Source File  |  1985-03-28  |  12KB  |  236 lines

  1. (*$C-,B-,U-,V-,R-,D+ *)
  2. Program PibList;
  3.  
  4. (*----------------------------------------------------------------------*)
  5. (*              PibList --- Turbo Pascal Ascii File Listing Program     *)
  6. (*----------------------------------------------------------------------*)
  7. (*                                                                      *)
  8. (*  Author:   Philip R. Burns                                           *)
  9. (*  Date:     March, 1985                                               *)
  10. (*  Version:  1.0                                                       *)
  11. (*  Systems:  For MS-DOS on IBM PCs and close compatibles only.         *)
  12. (*            Note:  I have checked these on Zenith 151s under          *)
  13. (*                   MSDOS 2.1 and IBM PCs under PCDOS 2.0.             *)
  14. (*                                                                      *)
  15. (*            NOTE:  THIS PROGRAM REQUIRES TURBO 3.0 OR LATER!          *)
  16. (*                                                                      *)
  17. (*  Overview: PibList will list an ascii file on the PC's screen.       *)
  18. (*            It combines most of the features found in other "browse"  *)
  19. (*            programs:                                                 *)
  20. (*                                                                      *)
  21. (*               -- Absolute and relative line numbers, screens, and    *)
  22. (*                  pages.                                              *)
  23. (*                                                                      *)
  24. (*               -- Very large file capability (any size file can be    *)
  25. (*                  listed).                                            *)
  26. (*                                                                      *)
  27. (*               -- A string search facility.                           *)
  28. (*                                                                      *)
  29. (*               -- Pages can be defined by a FF (Ascii 12) character,  *)
  30. (*                  or by ANSI carriage control '1' in column 1.        *)
  31. (*                                                                      *)
  32. (*               -- Support for color graphics screen if available.     *)
  33. (*                                                                      *)
  34. (*               -- Horizontal tab expansion.                           *)
  35. (*                                                                      *)
  36. (*               -- High-order bit stripping.                           *)
  37. (*                                                                      *)
  38. (*  Document: The file PIBLIST.DOC describes program usage in detail.   *)
  39. (*                                                                      *)
  40. (*----------------------------------------------------------------------*)
  41. (*                                                                      *)
  42. (*       Suggestions for improvements or corrections are welcome.       *)
  43. (*       Please leave messages on Gene Plantz's BBS (312) 882 4227      *)
  44. (*       or Ron Fox's BBS (312) 940 6496.                               *)
  45. (*                                                                      *)
  46. (*       I hope that you find this program useful -- and,               *)
  47. (*       if you expand upon it, please upload your extensions so        *)
  48. (*       that all of us can enjoy them!                                 *)
  49. (*                                                                      *)
  50. (*----------------------------------------------------------------------*)
  51.  
  52. (*$IPIBLIST.DOC*)
  53.  
  54.                    (*  Constant and type declarations  *)
  55.  
  56. (*$IGLOBTYPE.PAS*)
  57.  
  58. CONST
  59.  
  60.    Max_String    = 255        (* max string length             *);
  61.    Height        = 24         (* list window Height            *);
  62.    Max_buf_lines = 100        (* max number of lines in buffer *);
  63.    Max_buf_pages = 5          (* max number of pages in buffer *);
  64.    FF            = #12        (* form feed character           *);
  65.    TAB           = #9         (* tab character                 *);
  66.    CR            = #13        (* carriage return character     *);
  67.    LF            = #10        (* line feed character           *);
  68.    ESC           = #27        (* escape character              *);
  69.    NUL           = #0         (* null character                *);
  70.    Ctrlx         = ^X         (* line delete character         *);
  71.    BS            = #8         (* backspace character           *);
  72.    Buffer_Size   = 8191       (* Buffer size for input file    *);
  73.    Screen_Size   = 3936       (* Size of screen memory area    *)
  74.                               (* -- First 24 lines of 80 only  *);
  75.  
  76.                               (* Color/mono screen addresses   *)
  77.  
  78.    Color_Screen_Address = $B800;
  79.    Mono_Screen_Address  = $B000;
  80.  
  81.  
  82. TYPE
  83.  
  84.    Line_Ptr = ^Line            (* pointer to text line           *);
  85.  
  86.    Line =                      (* text line                      *)
  87.       RECORD
  88.          Next: Line_Ptr        (* pointer to next line in buffer *);
  89.          Lnum: REAL            (* line number                    *);
  90.          Pnum: REAL            (* page number                    *);
  91.          Txt:  AnyStr          (* text Line                      *);
  92.       END;
  93.  
  94.    CHAR6 = STRING[6];
  95.  
  96.    Fib_Record = RECORD         (* text file interface block      *)
  97.                    Handle:   INTEGER;
  98.                    Flags:    BYTE;
  99.                    CurCh:    CHAR;
  100.                    BufOff:   INTEGER;
  101.                    BufSize:  INTEGER;
  102.                    BufPtr:   INTEGER;
  103.                    BufEnd:   INTEGER;
  104.                 END;
  105.  
  106.    Fib_Ptr = ^Fib_Record;
  107.  
  108.    Buffer_Type  = PACKED ARRAY[0..Buffer_Size] OF CHAR;
  109.  
  110.    Buffer_Ptr = ^Buffer_Type;
  111.  
  112.    Screen_Type =  ARRAY[ 1 .. Screen_Size ] OF CHAR;
  113.  
  114.    Screen_Ptr  =  ^Screen_Type;
  115.  
  116.  
  117. (* Structured *) CONST
  118.                                 (* names for special chars *)
  119.  
  120.    Spec_Names: ARRAY [#0..#31] OF CHAR6
  121.  
  122.       =  ('<NUL> ', '<SOH> ', '<STX> ', '<ETX> ',
  123.           '<EOT> ', '<ENQ> ', '<ACK> ', '<BEL> ',
  124.           '<BS>  ', '<HT>  ', '<LF>  ', '<VT>  ',
  125.           '<FF>  ', '<CR>  ', '<SO>  ', '<SI>  ',
  126.           '<DLE> ', '<DC1> ', '<DC2> ', '<DC3> ',
  127.           '<DC4> ', '<NAK> ', '<SYN> ', '<ETB> ',
  128.           '<CAN> ', '<EM>  ', '<SUB> ', '<ESC> ',
  129.           '<FS>  ', '<GS>  ', '<RS>  ', '<US>  ');
  130.  
  131.                    (* Variable declarations *)
  132.  
  133. VAR
  134.  
  135.    F:           TEXT [Buffer_Size] (* file to be listed                     *);
  136.    F_Ptr:       Fib_Ptr            (* pointer to text file FIB              *);
  137.    First:       Line_Ptr           (* pointer to first line in buffer       *);
  138.    Last:        Line_Ptr           (* pointer to last line in buffer,       *)
  139.                                    (* or nil if buffer empty                *);
  140.    Top:         Line_Ptr           (* pointer to top line in viewing window *);
  141.    Bot:         Line_Ptr           (* pointer to bottom line in viewing     *)
  142.                                    (* window                                *);
  143.    Cur_line:    REAL               (* line number of next line on file f    *);
  144.    Cur_page:    REAL               (* page number of next line on file f    *);
  145.    Max_line:    REAL               (* max line number seen so far           *);
  146.    Max_page:    REAL               (* max page number seen so far           *);
  147.                                    (* command line                          *)
  148.    Command:     PACKED ARRAY[1..Max_String] OF CHAR;
  149.    Cind:        INTEGER            (* current position in command line      *);
  150.    First_col:   INTEGER            (* first col to be displayed             *);
  151.    Width:       INTEGER            (* screen width                          *);
  152.    Lpt:         BOOLEAN            (* TRUE if f has line printer carriage   *)
  153.                                    (* control                               *);
  154.    Nocc:        BOOLEAN            (* TRUE if f has no carriage control     *);
  155.    Eject_Char:  CHAR               (* '1' if lpt, else <FF>                 *);
  156.    Done:        BOOLEAN            (* TRUE when time to quit                *);
  157.    Eod:         BOOLEAN            (* TRUE if requested line or page        *)
  158.                                    (* is beyond end of file f               *);
  159.    Eof_seen:    BOOLEAN            (* TRUE if eof reached                   *);
  160.    Top_line:    REAL               (* line number of top line on currently  *)
  161.                                    (* displayed screen                      *);
  162.    One_Up:      BOOLEAN            (* If command is move up one line        *);
  163.    One_Down:    BOOLEAN            (* If command is move down one line      *);
  164.    Search_Str:  AnyStr             (* String to look for with search comm.  *);
  165.    Search_Lpos: INTEGER            (* Screen position of line containing    *)
  166.                                    (* searched string                       *);
  167.    Search_Line: REAL               (* Line number of line containing        *)
  168.                                    (* searched string                       *);
  169.    Search_Col:  INTEGER            (* Position of searched string in line   *);
  170.    Spec_Chars:  SET OF CHAR        (* unprintable characters                *);
  171.    Real_Screen: Screen_Ptr         (* Address of screen memory              *);
  172.    My_Screen  : Screen_Type        (* Area in which screen image is built   *);
  173.    Strip_High : BOOLEAN            (* TRUE to strip high-order bits         *);
  174.    Expand_Tabs: BOOLEAN            (* TRUE to expand horizontal tabs        *);
  175.  
  176. (*--------------------------------------------------------------------------*)
  177. (*                   Global Color Variables                                 *)
  178. (*--------------------------------------------------------------------------*)
  179.  
  180. Var
  181.  
  182.    ForeGround_Color : INTEGER      (* Color for ordinary text               *);
  183.    BackGround_Color : INTEGER      (* Usual background color                *);
  184.  
  185.    Help_Text_Color  : INTEGER      (* Color for help text                   *);
  186.    Spec_Chars_Color : INTEGER      (* Color for special/control chars       *);
  187.    Status_Line_Color: INTEGER      (* Color for status line                 *);
  188.    Search_Text_Color: INTEGER      (* Color for searched text               *);
  189.  
  190. (*$IMINMAX.PAS    *)
  191. (*$ISETCOLOR.PAS  *)
  192. (*$ISCREENLO.PAS  *)
  193. (*$ICLEARSCR.PAS  *)
  194. (*$IRESETF.PAS    *)
  195. (*$IREADLNF.PAS   *)
  196. (*$ICLEARBUF.PAS  *)
  197. (*$ISKIPS.PAS     *)
  198. (*$IREADLINE.PAS  *)
  199. (*$IFIND.PAS      *)
  200. (*$IFORMATLI.PAS  *)
  201. (*$IDISPLAYS.PAS  *)
  202. (*$IDISPLAYM.PAS  *)
  203. (*$INUMBER.PAS    *)
  204. (*$ISKIPBL.PAS    *)
  205. (*$IISSUEPRO.PAS  *)
  206. (*$IREADCOMM.PAS  *)
  207. (*$IPOSITION.PAS  *)
  208. (*$IPROMPT.PAS    *)
  209. (*$IINIT.PAS      *)
  210.  
  211. (*--------------------------------------------------------------------------*)
  212. (*                      PIBLIST -- Main Program                             *)
  213. (*--------------------------------------------------------------------------*)
  214.  
  215. (*--------------------------------------------------------------------------*)
  216. (*                                                                          *)
  217. (*       The main program initializes everything, and then repeatedly       *)
  218. (*       displays screens and prompts until an E command is entered.        *)
  219. (*       On termination the screen is cleared.                              *)
  220. (*                                                                          *)
  221. (*--------------------------------------------------------------------------*)
  222.  
  223. BEGIN (* PibList -- Main Program *)
  224.  
  225.    Initialize;
  226.  
  227.    WHILE ( NOT done ) DO
  228.       BEGIN
  229.          Display_Screen;
  230.          Prompt;
  231.       END;
  232.  
  233.    Clear_Screen;
  234.  
  235. END   (* PibList *).
  236.